﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using Entities;
using Business;
using DevComponents.DotNetBar;
namespace Presentation
{
    public partial class frmLapBaoCaoCongNo : DevComponents.DotNetBar.Office2007Form
    {
        public frmLapBaoCaoCongNo()
        {
            InitializeComponent();
        }

        private void btnLapBaoCao_Click(object sender, EventArgs e)
        {
            DateTime date = dtiThang.Value;
            string sThang = date.Month + "-" + date.Year;
            DataTable dt = BaoCaoCongNoService.LapBaoCao(date);
            if (dt == null)
            {
                MessageBoxEx.Show("Không tồn tại dữ liệu cho tháng " + sThang, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ReportDocument rpDoc = new ReportDocument();            
            rpDoc.Load(Application.StartupPath + @"\rpBaoCaoCongNo.rpt");
            

            //lấy object thang trong report
            TextObject objThang = (TextObject)rpDoc.ReportDefinition.Sections[0].ReportObjects["Thang"];
            objThang.Text = sThang;
            rpDoc.SetDataSource(dt);

            rpvBaoCaoCongNo.ReportSource = rpDoc;


        }

        private void frmLapBaoCaoCongNo_Load(object sender, EventArgs e)
        {
            dtiThang.Value = DateTime.Now;
        }

        
    }
}
